# -*- encoding: utf-8 -*-
import sys, smtplib
from email.mime.text import MIMEText  

config = {}
config['host'] = 'smtp.163.com'  
config['port'] = 465  
config['from'] = 'haojiash@163.com'  
config['pwd'] = '!!!!!!TO_BE_REPLACED!!!!!'  
config['to'] = 'elsd_uestc@groups.163.com' 
#config['to'] = 'haojiash@qq.com'

def sentemail():
    body = "".join(sys.stdin.readlines())
    msg = MIMEText(body, 'html') 
    msg['subject'] = 'Hello, welcome to ELSD programing!' 
    msg['from'] = config['from']
    msg['to'] = config['to']

    try:
	    s = smtplib.SMTP_SSL(config['host'], config['port'])  
	    s.login(config['from'], config['pwd'])
	    s.sendmail(config['from'], config['to'], msg.as_string())

	    print ('Done.sent email success')
    except smtplib.SMTPException:
	    print ('Error.sent email fail')
        
if __name__ == '__main__':
    sentemail()

